<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition template="/main-template.xhtml">

	<ui:define name="menu">

		<h:form>

			<rich:toolBar styleClass="toolBar">

				<rich:dropDownMenu>
					<f:facet name="label">
						<h:panelGroup>
							<h:outputText value="#{msg.label_users}" />
						</h:panelGroup>
					</f:facet>
					<rich:menuItem submitMode="ajax" value="#{msg.manageUsers}"
						action="users">
						<f:setPropertyActionListener value="list"
							target="#{userBean.currentState}"></f:setPropertyActionListener>
					</rich:menuItem>
					<rich:menuItem submitMode="ajax" value="#{msg.newUser}"
						action="#{userBean.prepareCreate}">
					</rich:menuItem>
				</rich:dropDownMenu>

				<rich:dropDownMenu>
					<f:facet name="label">
						<h:panelGroup>
							<h:outputText value="#{msg.label_process}" />
						</h:panelGroup>
					</f:facet>
					<rich:menuItem submitMode="ajax" value="#{msg.manageProcesses}"
						action="process">
						<f:setPropertyActionListener target="#{processBean.currentState}"
							value="list" />
					</rich:menuItem>
					<rich:menuItem submitMode="ajax" value="#{msg.newProcess}"
						action="#{processBean.prepareCreate}">
						<f:setPropertyActionListener target="#{processBean.currentState}"
							value="create" />
					</rich:menuItem>
				</rich:dropDownMenu>

			</rich:toolBar>

		</h:form>


	</ui:define>

	<ui:define name="content">

		<a4j:outputPanel id="create"
			rendered="#{userBean.currentState == 'create'}">
			<h1><h:outputText value="#{msg.createUser}" /></h1>

			<div id="createForm"><rich:panel>

				<h:form id="userForm">
					<h:panelGrid columns="2">

						<h:outputText value="#{msg.role}" />
						<h:selectOneMenu id="Roles" value="#{userBean.role}">
							<f:selectItem id="admin" itemLabel="#{msg.admin}"
								itemValue="admin" />
							<f:selectItem id="standardUser" itemLabel="#{msg.client}"
								itemValue="user" />
							<a4j:support event="onchange" reRender="userForm"
								ajaxSingle="true" />
						</h:selectOneMenu>


						<h:outputText value="#{msg.type}"
							rendered="#{userBean.role != 'admin'}" />
						<h:selectOneRadio value="#{userBean.type}" onclick=""
							valueChangeListener="#{userBean.processValueChange}"
							rendered="#{userBean.role != 'admin'}">
							<f:selectItem itemValue="PessoaFisica" itemLabel="#{msg.pfisica}" />
							<f:selectItem itemValue="PessoaJuridica"
								itemLabel="#{msg.pjuridica}" />
							<a4j:support event="onchange" reRender="userForm"
								ajaxSingle="true" />
						</h:selectOneRadio>


						<h:outputLabel value="#{msg.name}*" />
						<h:panelGroup>
							<h:inputText value="#{userBean.name}" id="name" required="true" validator="validateName"/>
							<rich:message for="name">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.datanasc}"
							rendered="#{userBean.renderf and userBean.role != 'admin'}" />
						<h:panelGroup
							rendered="#{userBean.renderf and userBean.role != 'admin'}">
							<rich:calendar value="#{userBean.birthdate}"
								rendered="#{userBean.renderf and userBean.role != 'admin'}"
								id="data" datePattern="dd/MM/yyyy" enableManualInput="true">
								<f:convertDateTime type="date" />
							</rich:calendar>
							
							<rich:message for="data"
								rendered="#{userBean.renderf and userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.username}*" />
						<h:panelGroup>
							<h:inputText value="#{userBean.username}" id="username"
								required="true" />
							<rich:message for="username">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>


						<h:outputLabel value="#{msg.password}*" />
						<h:panelGroup>
							<h:inputSecret value="#{userBean.password}" id="password"
								required="true"  binding="#{userBean.passwordInput}"/>
							<rich:message for="password">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.confirmPassword}*" />
						<h:panelGroup>
							<h:inputSecret value="#{userBean.confirmPassword}"
								id="confirmpassword" required="true" />
							<rich:message for="confirmpassword">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.phone}"
							rendered="#{userBean.role != 'admin'}" />
						<h:panelGroup rendered="#{userBean.role != 'admin'}">
							<h:inputText value="#{userBean.phone}"
								rendered="#{userBean.role != 'admin'}" id="phone" />
							<rich:message for="phone" rendered="#{userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.cpf}"
							rendered="#{userBean.renderf and userBean.role != 'admin'}" />
						<h:panelGroup
							rendered="#{userBean.renderf and userBean.role != 'admin'}">
							<h:inputText value="#{userBean.cpf}"
								rendered="#{userBean.renderf and userBean.role != 'admin'}"
								id="cpf" required="true" />
							<rich:message for="cpf"
								rendered="#{userBean.renderf and userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.cnpj}"
							rendered="#{userBean.renderj and userBean.role != 'admin'}" />
						<h:panelGroup
							rendered="#{userBean.renderj and userBean.role != 'admin'}">
							<h:inputText value="#{userBean.cnpj}"
								rendered="#{userBean.renderj and userBean.role != 'admin'}"
								id="cnpj" required="true" />
							<rich:message for="cnpj"
								rendered="#{userBean.renderj and userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel for="address" value="#{msg.address}"
							rendered="#{userBean.role != 'admin'}" />
						<h:panelGroup rendered="#{userBean.role != 'admin'}">
							<h:inputTextarea id="address" value="#{userBean.address}"
								rendered="#{userBean.role != 'admin'}" />
							<rich:message for="address"
								rendered="#{userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.compDescription}"
							rendered="#{userBean.renderj and userBean.role != 'admin'}" />
						<h:panelGroup
							rendered="#{userBean.renderj and userBean.role != 'admin'}">
							<h:inputTextarea value="#{userBean.description}"
								rendered="#{userBean.renderj and userBean.role != 'admin'}"
								id="description" />
							<rich:message for="description"
								rendered="#{userBean.renderj and userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>
						<h:panelGroup />
						<h:panelGroup />
						<h:panelGroup>
							<a4j:commandButton value="#{msg.newUser}"
								action="#{userBean.createAction}">
								<f:setPropertyActionListener target="#{userBean.currentState}"
									value="list" />
							</a4j:commandButton>

							<a4j:commandButton value="#{msg.cancel}" action="users"
								immediate="true">
								<f:setPropertyActionListener target="#{userBean.currentState}"
									value="list"></f:setPropertyActionListener>
							</a4j:commandButton>
						</h:panelGroup>
					</h:panelGrid>
				</h:form>
			</rich:panel></div>
		</a4j:outputPanel>

		<a4j:outputPanel id="edit"
			rendered="#{userBean.currentState == 'edit'}">
			<h1><h:outputText value="#{msg.editUser}" /></h1>

			<div id="editForm"><rich:panel>

				<h:form id="userEditForm">
					<h:panelGrid columns="2">

						<h:outputText value="#{msg.type}"
							rendered="#{userBean.role != 'admin'}" />
						<h:selectOneRadio value="#{userBean.type}"
							valueChangeListener="#{userBean.processValueChange}"
							rendered="#{userBean.role != 'admin'}">
							<f:selectItem itemValue="PessoaFisica" itemLabel="#{msg.pfisica}" />
							<f:selectItem itemValue="PessoaJuridica"
								itemLabel="#{msg.pjuridica}" />
							<a4j:support event="onchange" reRender="userEditForm"
								ajaxSingle="true" />
						</h:selectOneRadio>


						<h:outputLabel value="#{msg.name}*" />
						<h:panelGroup>
							<h:inputText value="#{userBean.name}" id="name" required="true" />
							<rich:message for="name">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.datanasc}"
							rendered="#{userBean.renderf and userBean.role != 'admin'}" />
						<h:panelGroup
							rendered="#{userBean.renderf and userBean.role != 'admin'}">
							<rich:calendar  value="#{userBean.birthdate}"
								rendered="#{userBean.renderf and userBean.role != 'admin'}"
								id="data" enableManualInput="true">
								<f:convertDateTime type="date" />
							</rich:calendar>
							<rich:message for="data"
								rendered="#{userBean.renderf and userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.username}*" />
						<h:panelGroup>
							<h:inputText value="#{userBean.username}" id="username"
								required="true" />
							<rich:message for="username">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>


						<h:outputLabel value="#{msg.password}*" />
						<h:panelGroup>
							<h:inputSecret value="#{userBean.password}" id="password"
								required="true" />
							<rich:message for="password">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.confirmPassword}*" />
						<h:panelGroup>
							<h:inputSecret value="#{userBean.confirmPassword}"
								id="confirmpassword" required="true" />
							<rich:message for="confirmpassword">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.phone}"
							rendered="#{userBean.role != 'admin'}" />
						<h:panelGroup rendered="#{userBean.role != 'admin'}">
							<h:inputText value="#{userBean.phone}"
								rendered="#{userBean.role != 'admin'}" id="phone" />
							<rich:message for="phone" rendered="#{userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.cpf}"
							rendered="#{userBean.renderf and userBean.role != 'admin'}" />
						<h:panelGroup
							rendered="#{userBean.renderf and userBean.role != 'admin'}">
							<h:inputText value="#{userBean.cpf}"
								rendered="#{userBean.renderf and userBean.role != 'admin'}"
								id="cpf" required="true" />
							<rich:message for="cpf"
								rendered="#{userBean.renderf and userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.cnpj}"
							rendered="#{userBean.renderj and userBean.role != 'admin'}" />
						<h:panelGroup
							rendered="#{userBean.renderj and userBean.role != 'admin'}">
							<h:inputText value="#{userBean.cnpj}"
								rendered="#{userBean.renderj and userBean.role != 'admin'}"
								id="cnpj" required="true" />
							<rich:message for="cnpj"
								rendered="#{userBean.renderj and userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel for="address" value="#{msg.address}"
							rendered="#{userBean.role != 'admin'}" />
						<h:panelGroup rendered="#{userBean.role != 'admin'}">
							<h:inputTextarea id="address" value="#{userBean.address}"
								rendered="#{userBean.role != 'admin'}" />
							<rich:message for="address"
								rendered="#{userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>

						<h:outputLabel value="#{msg.compDescription}"
							rendered="#{userBean.renderj and userBean.role != 'admin'}" />
						<h:panelGroup
							rendered="#{userBean.renderj and userBean.role != 'admin'}">
							<h:inputTextarea value="#{userBean.description}"
								rendered="#{userBean.renderj and userBean.role != 'admin'}"
								id="description" />
							<rich:message for="description"
								rendered="#{userBean.renderj and userBean.role != 'admin'}">
								<f:facet name="passedMarker">
									<h:graphicImage value="/images/passed.png" />
								</f:facet>
								<f:facet name="errorMarker">
									<h:graphicImage value="/images/error.png" />
								</f:facet>
							</rich:message>
						</h:panelGroup>
						<h:panelGroup />
						<h:panelGroup />
						<h:panelGroup>
							<a4j:commandButton value="#{msg.editUser}"
								action="#{userBean.editAction}">
								<f:setPropertyActionListener target="#{userBean.currentState}"
									value="list" />
							</a4j:commandButton>

							<a4j:commandButton value="#{msg.cancel}" action="users"
								immediate="true">
								<f:setPropertyActionListener target="#{userBean.currentState}"
									value="list"></f:setPropertyActionListener>
							</a4j:commandButton>
						</h:panelGroup>
					</h:panelGrid>
				</h:form>
			</rich:panel></div>
		</a4j:outputPanel>

		<a4j:outputPanel id="remove"
			rendered="#{userBean.currentState == 'remove'}">
			<h1><h:outputText value="#{msg.removeUser}" /></h1>

			<div id="createForm">
			<h5><h:outputText value="#{msg.confirmRemove}" /></h5>
			<rich:panel>

				<h:form id="userRemoveForm">
					<h:panelGrid columns="2">

						<h:outputText value="#{msg.role}" />
						<h:outputLabel value="#{userBean.role}" />

						<h:outputLabel value="#{msg.name}*" />
						<h:outputText value="#{userBean.name}" id="name" />

						<h:outputLabel value="#{msg.datanasc}"
							rendered="#{userBean.renderf and userBean.role != 'admin'}" />
						<h:outputText value="#{userBean.birthdate}"
							rendered="#{userBean.renderf and userBean.role != 'admin'}">
							<f:convertDateTime dateStyle="short" />
						</h:outputText>

						<h:outputLabel value="#{msg.username}*" />
						<h:outputText value="#{userBean.username}" id="username" />

						<h:outputLabel value="#{msg.phone}"
							rendered="#{userBean.role != 'admin'}" />
						<h:outputText value="#{userBean.phone}"
							rendered="#{userBean.role != 'admin'}" id="phone" />

						<h:outputLabel value="#{msg.cpf}"
							rendered="#{userBean.renderf and userBean.role != 'admin'}" />
						<h:outputText value="#{userBean.cpf}"
							rendered="#{userBean.renderf and userBean.role != 'admin'}"
							id="cpf" />

						<h:outputLabel value="#{msg.cnpj}"
							rendered="#{userBean.renderj and userBean.role != 'admin'}" />
						<h:outputText value="#{userBean.cnpj}"
							rendered="#{userBean.renderj and userBean.role != 'admin'}"
							id="cnpj" />

						<h:outputLabel for="address" value="#{msg.address}"
							rendered="#{userBean.role != 'admin'}" />
						<h:outputText id="address" value="#{userBean.address}"
							rendered="#{userBean.role != 'admin'}" />

						<h:outputLabel value="#{msg.compDescription}"
							rendered="#{userBean.renderj and userBean.role != 'admin'}" />
						<h:outputText value="#{userBean.description}"
							rendered="#{userBean.renderj and userBean.role != 'admin'}"
							id="description" />

						<h:panelGroup />
						<h:panelGroup />
						<h:panelGroup>
							<a4j:commandButton value="#{msg.removeUser}"
								action="#{userBean.removeAction}">
								<f:setPropertyActionListener target="#{userBean.currentState}"
									value="list" />
							</a4j:commandButton>

							<a4j:commandButton value="#{msg.cancel}" action="users"
								immediate="true">
								<f:setPropertyActionListener target="#{userBean.currentState}"
									value="list"></f:setPropertyActionListener>
							</a4j:commandButton>
						</h:panelGroup>
					</h:panelGrid>
				</h:form>
			</rich:panel></div>
		</a4j:outputPanel>

		<a4j:outputPanel id="list"
			rendered="#{userBean.currentState == 'list'}">

			<h1><h:outputText value="#{msg.usersList}" /></h1>
			<a4j:form>
				<h:outputText value="Selecione que tipo de usuario exibir: " />
				<h:selectOneMenu id="ViewStates" value="#{userBean.viewState}"
					style="margin:15px 0px;">
					<f:selectItem id="admin" itemLabel="#{msg.user_table_admin}"
						itemValue="admin" />
					<f:selectItem id="userPF" itemLabel="#{msg.user_table_userPF}"
						itemValue="userPF" />
					<f:selectItem id="userPJ" itemLabel="#{msg.user_table_userPJ}"
						itemValue="userPJ" />
					<a4j:support event="onchange" reRender="list" ajaxSingle="true" />
				</h:selectOneMenu>
			</a4j:form>

			<a4j:outputPanel id="admins"
				rendered="#{userBean.viewState == 'admin'}">
				<a4j:form>

					<rich:dataTable value="#{userBean.usersAdmin}" var="user"
						columns="5" width="100%" rowClasses="odd,even" style="text-align:center;">

						<f:facet name="header">

							<h:outputText value="#{msg.user_table_admin}" />

						</f:facet>

						<rich:column sortBy="#{user.id}">

							<f:facet name="header">
								<h:outputText value="#{msg.user_id}" />
							</f:facet>
							<h:outputText value="#{user.id}" />
						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_name}" />
							</f:facet>

							<h:outputText value="#{user.name}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_username}" />
							</f:facet>

							<h:outputText value="#{user.username}" />

						</rich:column>


						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_role}" />
							</f:facet>

							<h:outputText value="#{user.role}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_actions}" />
							</f:facet>

							<a4j:commandButton image="images/bt_edit.png"
								action="#{userBean.prepareEditAdmin}">
								<f:setPropertyActionListener value="#{user}"
									target="#{userBean.selectedUserAdmin}" />
							</a4j:commandButton>
							<a4j:commandButton image="images/bt_delete.png"
								action="#{userBean.prepareRemoveAdmin}" rendered="#{authBean.userLogado != user}">
								<f:setPropertyActionListener value="#{user}"
									target="#{userBean.selectedUserAdmin}" />
							</a4j:commandButton>

						</rich:column>

						<f:facet name="footer">

							<h:outputText value="#{msg.table_actions}" />

						</f:facet>

					</rich:dataTable>


				</a4j:form>
			</a4j:outputPanel>

			<a4j:outputPanel id="usersPF"
				rendered="#{userBean.viewState == 'userPF'}">


				<a4j:form>

					<rich:dataTable value="#{userBean.usersPF}" var="user" columns="9"
						width="100%" rowClasses="odd,even" style="text-align:center;">

						<f:facet name="header">

							<h:outputText value="#{msg.user_table_userPF}" />

						</f:facet>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_id}" />
							</f:facet>
							<h:outputText value="#{user.id}" />
						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_name}" />
							</f:facet>

							<h:outputText value="#{user.name}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_username}" />
							</f:facet>

							<h:outputText value="#{user.username}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_cpf}" />
							</f:facet>

							<h:outputText value="#{user.cpf}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_bithdate}" />
							</f:facet>

							<h:outputText value="#{user.birthdate}">
								<f:convertDateTime dateStyle="short" />
							</h:outputText>
						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_phone}" />
							</f:facet>

							<h:outputText value="#{user.phone}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_address}" />
							</f:facet>

							<h:outputText value="#{user.address}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_role}" />
							</f:facet>

							<h:outputText value="#{user.role}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_actions}" />
							</f:facet>

							<a4j:commandButton image="images/bt_edit.png"
								action="#{userBean.prepareEditUserPF}">
								<f:setPropertyActionListener value="#{user}"
									target="#{userBean.selectedUserPF}" />
							</a4j:commandButton>
							<a4j:commandButton image="images/bt_delete.png"
								action="#{userBean.prepareRemoveUserPF}" >
								<f:setPropertyActionListener value="#{user}"
									target="#{userBean.selectedUserPF}" />
							</a4j:commandButton>
							

						</rich:column>

						<f:facet name="footer">

							<h:outputText value="#{msg.table_actions}" />

						</f:facet>

					</rich:dataTable>


				</a4j:form>


			</a4j:outputPanel>

			<a4j:outputPanel id="usersPJ"
				rendered="#{userBean.viewState == 'userPJ'}">


				<a4j:form>

					<rich:dataTable value="#{userBean.usersPJ}" var="user" columns="9"
						width="100%" rowClasses="odd,even" style="text-align:center;">

						<f:facet name="header">

							<h:outputText value="#{msg.user_table_userPJ}" />

						</f:facet>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_id}" />
							</f:facet>
							<h:outputText value="#{user.id}" />
						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_name}" />
							</f:facet>

							<h:outputText value="#{user.name}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_username}" />
							</f:facet>

							<h:outputText value="#{user.username}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_cnpj}" />
							</f:facet>

							<h:outputText value="#{user.cnpj}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_description}" />
							</f:facet>

							<h:outputText value="#{user.description}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_phone}" />
							</f:facet>

							<h:outputText value="#{user.phone}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_address}" />
							</f:facet>

							<h:outputText value="#{user.address}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_role}" />
							</f:facet>

							<h:outputText value="#{user.role}" />

						</rich:column>

						<rich:column>

							<f:facet name="header">
								<h:outputText value="#{msg.user_actions}" />
							</f:facet>

							<a4j:commandButton image="images/bt_edit.png"
								action="#{userBean.prepareEditUserPJ}">
								<f:setPropertyActionListener value="#{user}"
									target="#{userBean.selectedUserPJ}" />
							</a4j:commandButton>
							<a4j:commandButton image="images/bt_delete.png"
								action="#{userBean.prepareRemoveUserPJ}">
								<f:setPropertyActionListener value="#{user}"
									target="#{userBean.selectedUserPJ}" />
							</a4j:commandButton>

						</rich:column>

						<f:facet name="footer">

							<h:outputText value="#{msg.table_actions}" />

						</f:facet>

					</rich:dataTable>


				</a4j:form>


			</a4j:outputPanel>

		</a4j:outputPanel>

	</ui:define>
</ui:composition>



</html>